#include <iostream>
#include <fstream>
#include <unordered_map>
#include <string>
#include "logtxt.hpp"
#include <stdlib.h>
extern Log lg;
using namespace std;
string cell = ":";
string filename = "./text.txt";
void split(const string &line, string &part1, string &part2)
{
    int pos = line.find(cell);
    part1 = line.substr(0, pos);
    part2 = line.substr(pos + 1, line.npos);
}
class Init
{
private:
    unordered_map<string, string> dict;

public:
    Init()
    {
        ifstream ins(filename);
        if (!ins.is_open())
        {
            lg(fatal, "ifstream open %s error", filename.c_str());
            exit(1);
        }
        string line;
        while (getline(ins, line))
        {
            string part1, part2;
            split(line, part1, part2);
            dict.insert({part1, part2});
        }
        ins.close();
    }

    string tranlation(const string &str)
    {
        auto iter = dict.find(str);
        if (iter != dict.end())
        {
            return iter->second;
        }
        else
        {
            return "Unknow";
        }
    }
};